package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OfficialstudentMapper;
import com.ruoyi.system.domain.Officialstudent;
import com.ruoyi.system.service.IOfficialstudentService;
import com.ruoyi.common.core.text.Convert;

import javax.annotation.Resource;

/**
 * 正式学生Service业务层处理
 *
 * @author ruoyi
 * @date 2021-11-09
 */
@Service
public class OfficialstudentServiceImpl implements IOfficialstudentService
{
    @Resource
    private OfficialstudentMapper officialstudentMapper;

    /**
     * 查询正式学生
     *
     * @param regularId 正式学生主键
     * @return 正式学生
     */
    @Override
    public Officialstudent selectOfficialstudentByRegularId(String regularId)
    {
        return officialstudentMapper.selectOfficialstudentByRegularId(regularId);
    }

    /**
     * 查询正式学生列表
     *
     * @param officialstudent 正式学生
     * @return 正式学生
     */
    @Override
    public List<Officialstudent> selectOfficialstudentList(Officialstudent officialstudent)
    {

        return officialstudentMapper.selectOfficialstudentList(officialstudent);
    }

    /**
     * 新增正式学生
     *
     * @param officialstudent 正式学生
     * @return 结果
     */
    @Override
    public int insertOfficialstudent(Officialstudent officialstudent)
    {
        if (officialstudent.getRegularId() == null||"".equals(officialstudent.getRegularId())){
            String uuid = UUID.randomUUID().toString();
            String id="PHID"+ DateUtils.dateTime()+uuid.substring(uuid.length()-5,uuid.length()-1);
            officialstudent.setRegularId(id);
        }
        return officialstudentMapper.insertOfficialstudent(officialstudent);
    }

    /**
     * 修改正式学生
     *
     * @param officialstudent 正式学生
     * @return 结果
     */
    @Override
    public int updateOfficialstudent(Officialstudent officialstudent)
    {
        return officialstudentMapper.updateOfficialstudent(officialstudent);
    }

    /**
     * 批量删除正式学生
     *
     * @param regularIds 需要删除的正式学生主键
     * @return 结果
     */
    @Override
    public int deleteOfficialstudentByRegularIds(String regularIds)
    {
        return officialstudentMapper.deleteOfficialstudentByRegularIds(Convert.toStrArray(regularIds));
    }

    /**
     * 删除正式学生信息
     *
     * @param regularId 正式学生主键
     * @return 结果
     */
    @Override
    public int deleteOfficialstudentByRegularId(String regularId)
    {
        return officialstudentMapper.deleteOfficialstudentByRegularId(regularId);
    }
}
